﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace DrawableObjects.Actors.Weapons
{
    public class WeaponUpgrade : Item
    {
        public Weapon.WeaponType weaponCategory
        {
            get;
            private set;
        }
        /// <summary>
        /// when the item is picked up, it is being removed from the world.
        /// </summary>
        public override void collide(Actor actor2)
        {
            if (actor2.owner == Owner.PLAYER) {
                world.removeActor(this);
            }
        }


        private WeaponUpgrade(Weapon.WeaponType weaponCategory, string strTextureModel, Matrix worldMatrix, float scaleFactor, float boundingFactor)
            : base(strTextureModel, worldMatrix, scaleFactor, boundingFactor)
        {
            this.weaponCategory = weaponCategory;
        }

        /// <summary>
        /// creates the weaponupgrade-item with the correct texture for the affected weaponcategory
        /// </summary>
        public static WeaponUpgrade GET_UPGRADEITEM(Weapon.WeaponType weaponCategory)
        {
            Matrix worldMatrix = Matrix.CreateScale(0.4f) * Matrix.CreateWorld(new Vector3(0, GlobalGameClasses.GlobalGameValues.GAMEFIELD_HEIGHT, 0), Vector3.Backward, Vector3.Up);
            string modelTexture = null;
            switch (weaponCategory)
            {
                case Weapon.WeaponType.Laser:
                    modelTexture = "item_Laser";
                    break;
                case Weapon.WeaponType.Plasma:
                    modelTexture = "item_Plasma";
                    break;
                case Weapon.WeaponType.Missile:
                    modelTexture = "item_Missile";
                    break;
            }
            WeaponUpgrade item = new WeaponUpgrade(weaponCategory, modelTexture, worldMatrix, 0.03f, 1);
            return item;
        }

        public static WeaponUpgrade GET_DUMMY_UPGRADE()
        {
            return new WeaponUpgrade(Weapon.WeaponType.Laser, "item_LaserMod", Matrix.CreateWorld(new Vector3(100, 0, 0), Vector3.Backward, Vector3.Up), 0, 0);
        }

    }
}

